package com.beyond.project.action;

import java.util.ArrayList;
import java.util.List;

import com.beyond.project.service.ProjectDeleteService;
import com.beyond.project.service.ProjectFindOneService;
import com.beyond.project.service.ProjectInsertService;
import com.beyond.project.service.ProjectListService;
import com.beyond.project.service.ProjectUpdateService;
import com.beyond.project.vo.ProjectBean;

import net.common.action.GeneralAction;

public class ProjectAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private ProjectBean bean = new ProjectBean();
	private List<ProjectBean> list = new ArrayList<ProjectBean>();
	
	
	public String listAll() throws Exception {
		ProjectListService service = new ProjectListService();
		service.setPageBean(pageBean);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}
	
	public String add() throws Exception {
		ProjectInsertService service = new ProjectInsertService();
		service.setProject(bean);
		service.invoke();
		return SUCCESS;
	}
	
	public String update() throws Exception{
		ProjectUpdateService service = new ProjectUpdateService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}
	
	public String findOne() throws Exception {
		if(bean.getProjectId() != null) {			
			ProjectFindOneService service = new ProjectFindOneService();
			service.setId(bean.getProjectId());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}
	
	public String delete() throws Exception {
		ProjectDeleteService service = new ProjectDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public ProjectBean getBean() {
		return bean;
	}

	public void setBean(ProjectBean bean) {
		this.bean = bean;
	}

	public List<ProjectBean> getList() {
		return list;
	}

	public void setList(List<ProjectBean> list) {
		this.list = list;
	}	
}
